/*******************************************************************************
Platform : AVR mega16学习板（www.iccavr.com）
Project  : 实验二五：LCD1602B八线制驱动实验
Clock F  : 8M
Software : ICCAVR7.14C
Author   : 林夕依然
Version  : 09.03.09
Updata   : 09.04.28  增加了proteus仿真模型，调试通过。
		   09.08.02  优化程序，不会再出现乱码，清屏指令后加延时
comments :
1、八线制：PB0-PB7为数据线，PD3/PD4/PD6控制LCD1602B的RS,RW,EN。
2、模块化编程。
3、学习板为“ICCAVR ”网站的AVR mega16学习板.
*******************************************************************************/
#include <avr/io.h>
#include <util/delay.h>
#include "LCD1602.h"

void main(void)
{
    Port_init();//端口初始化
	LCD_init(); //LCD初始化
	LCD_clear();//清屏
	LCD_write_str(0,0,"abcdefghijklmnop");
	LCD_write_str(0,1,"ABCDEFGHIJKLMNOP");
	_delay_ms(2000);
	LCD_clear();//清屏
	
	while (1) 
	  {
	  	uchar i=0,j=0;
	    uchar *p="I love tingting!";
		uchar *q="I love aumed!";
		
	    LCD_write_str(0,0,"09.03.09-22:22");
	    LCD_write_str(0,1,"1985-03-29");
	    _delay_ms(2000);
		LCD_clear();//清屏
		
		LCD_write_str(0,0,"605987969@qq.com");
	    LCD_write_str(0,1,"www.hao123.com");
	    _delay_ms(2000);
		LCD_clear();//清屏
		
		LCD_write_str(0,0,"LCD1602B");
		LCD_write_str(0,1,"linxiyiran");
		_delay_ms(2000);
		LCD_clear();//清屏
		
		while (*p) 
		 {
			LCD_write_char(i,0,*p);
			i++;
			p++;
			_delay_ms(100);
		 }
		 		
		while (*q) 
		 {
			LCD_write_char(j,1,*q);
			j++;
			q++;
			_delay_ms(100);
		 }
		 
		 _delay_ms(2000);
		 LCD_clear();//清屏
	  }
}
